@extends('admin.default')
@section('title', '管理员列表')
@section('content')
        <div class="layui-fluid">
            <div class="layui-row">
                <form class="layui-form">
                  <div class="layui-form-item">
                      <label for="username" class="layui-form-label">
                          当前用户：
                      </label>
                      <div class="layui-input-inline">
                          <input type="text" id="username" name="username" autocomplete="off" class="layui-input" value="{{$manager->username}}" disabled>
                      </div>
                      <div class="layui-form-mid layui-word-aux">

                      </div>
                  </div>
                  <div class="layui-form-item">
                      <label for="phone" class="layui-form-label">
                           手机
                      </label>
                      <div class="layui-input-inline">
                          <input type="text" id="phone" name="mobile" autocomplete="off" class="layui-input" value="{{$manager->mobile}}">
                      </div>
                      <div class="layui-form-mid layui-word-aux">

                      </div>
                  </div>
                  <div class="layui-form-item">
                      <label for="L_email" class="layui-form-label">
                          <span class="x-red">*</span>邮箱
                      </label>
                      <div class="layui-input-inline">
                          <input type="text" id="L_email" name="email" class="layui-input" value="{{$manager->email}}">
                      </div>

                  </div>

                  <div class="layui-form-item">
                      <label for="L_pass" class="layui-form-label">
                          <span class="x-red">*</span>密码
                      </label>
                      <div class="layui-input-inline">
                          <input type="password" id="password" name="password" required="" lay-verify="pass" autocomplete="off" class="layui-input">
                      </div>
                      <div class="layui-form-mid layui-word-aux">
                          6到16个字符
                      </div>
                  </div>
                  <div class="layui-form-item">
                      <label for="L_repass" class="layui-form-label">
                          <span class="x-red">*</span>确认密码
                      </label>
                      <div class="layui-input-inline">
                          <input type="password" id="password_confirmation" name="password_confirmation" required="" lay-verify="repass" autocomplete="off" class="layui-input">
                          <input type="hidden" name="_method" value="PUT">
                          <input type="hidden" name="_token" value="{{ csrf_token() }}">
                      </div>
                  </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="x-red">*</span>状态</label>
                        <div class="layui-input-block">
                            <input type="checkbox" name="status" lay-skin="switch" lay-text="启用|禁用" value="1" @if($manager->status==1)checked @endif>
                        </div>
                    </div>
                  <div class="layui-form-item">
                      <label for="L_repass" class="layui-form-label">
                      </label>
                      <button  class="layui-btn" lay-filter="edit" lay-submit="">
                          修改
                      </button>
                  </div>
              </form>
            </div>
        </div>
        <script>layui.use(['form', 'layer'],
            function() {
                $ = layui.jquery;
                var form = layui.form,
                layer = layui.layer;
                form.on('submit(edit)',
                function(data) {
                    data = data.field;
                    $.ajax({
                        type: 'POST',
                        url: '{{route('admin.manager.update',$manager->id)}}',
                        data: data,
                        dataType: 'json',
                        success: function (data){
                            if(data == 1){
                                layer.alert('修改成功', {
                                    icon: 1,
                                    skin: 'layui-layer-molv' //样式类名
                                    ,closeBtn: 0
                                }, function(){
                                    var index = parent.layer.getFrameIndex(window.name);
                                    parent.layer.close(index);
                                    parent.location.reload();
                                });
                            } else{
                                layer.alert('修改失敗', {
                                    icon: 2,
                                    skin: 'layui-layer-molv' //样式类名
                                    ,closeBtn: 0
                                });
                            }
                        },
                        error: function(res){
                            var msg=JSON.parse(res.responseText);
                            layer.alert(msg.message, {
                                icon: 2,
                                title: '提示信息',
                                skin: 'layui-layer-molv' //样式类名
                                ,closeBtn: 0
                            });
                        }
                    });
                    //发异步，把数据提交给php

                    return false;
                });

            });</script>
@stop
